# 1. 定义一个指定内核源码路径的变量
# ubuntu系统的内核源码的路径

arch := arm
ifeq ($(arch),x86)
	KERNEL_DIR := /lib/modules/$(shell uname -r)/build
	CROSS_COMPILE ?= 
else
	KERNEL_DIR := /home/linux/linux-5.10.61
	CROSS_COMPILE ?= arm-linux-gnueabihf-
endif

cc := $(CROSS_COMPILE)gcc
# 2. 定义一个当前驱动代码的路径的变量
CURRENT_DIR := $(shell pwd)

all:
	make -C $(KERNEL_DIR) M=$(CURRENT_DIR) modules

install:
	@ cp *.ko  ~/rootfs
	@# cp $(appname) ~/rootfs

clean:
	make -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
	@# rm $(appname)

obj-m := $(modname).o 